package hotel.board.circuit;

import hotel.exception.BuildingsMissingException;
import hotel.exception.NotEnoughPlaceException;

class ModifiableCase extends Case implements IModifiableCase{
	
	// CONSTRUCTEURS

	public ModifiableCase(ICase c) {
		super(c.getProperty(RIGHT_SIDE), c.getProperty(LEFT_SIDE), c.getState());
	}
	
	// COMMANDES

	@Override
	public void buildEntry(int side) throws NotEnoughPlaceException, BuildingsMissingException {
		if (getProperty(side) == null) {
			throw new BuildingsMissingException();
		}
		if (rightEntry || leftEntry) {
			throw new NotEnoughPlaceException();
		}
		switch (side) {
		case RIGHT_SIDE:
			rightEntry = true;
			break;
		case LEFT_SIDE:
			leftEntry = true;
			break;
		}
		throw new IllegalArgumentException();
	}

}
